package com.jn.algorithm.other.question2000;

/**
 * @author 江南大学1033190417
 * @date 2022/5/21 23:53
 */
public class Solution {
    public String reversePrefix(String word, char ch) {
        int indexOfCh = word.indexOf(ch);
        if (indexOfCh ==-1){
            return word;
        }
        StringBuilder stringBuilder=new StringBuilder(word.substring(0, indexOfCh+1));
        stringBuilder.reverse();
        stringBuilder.append(word.substring(indexOfCh+1));
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        Solution solution=new Solution();
        System.out.println(solution.reversePrefix("abcdefd", 'd'));
    }
}
